package cn.snowsoft.iot.module.cps.utils;

import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class StringToList {

    public static List<Long> toLongList (String str) {
        String[] numbersArray = str.split(",");
        List<Long> numbersList = new ArrayList<>();
        for (String numStr : numbersArray) {
            try {
                numbersList.add(Long.parseLong(numStr));
            } catch (NumberFormatException e) {
                System.err.println("转换错误: " + numStr + " 不是有效的数字");
            }
        }

        return numbersList;
    }
}
